// 机票查询相关类型定义

export interface Carrier {
  carrier: string;
}

export interface Location {
  dept: string;
}

export interface Destination {
  arr: string;
}

export interface FlightList {
  id?: string;
  fno?: string;
  dept?: string;
  arr?: string;
  carrier?: string;
  depttime?: string | Date;
}

// 价格趋势相关类型
export interface PriceTrendData {
  id: string;
  price: number;
  createtime: string | Date;
  decrease_flag: number; // 1表示价格下降，0表示不下降
}

export interface FlightPriceTrendResponse extends BaseResponse {
  data: PriceTrendData[] | null;
}

export interface FlightQueryCondition {
  current_page?: number;
  page_size?: number;
  dept?: string;
  arr?: string;
  depttime_start?: string;
  depttime_end?: string;
  fno?: string;
  carrier?: string;
  min_price?: number;
  max_price?: number;
}

export interface BaseResponse<T = any> {
  code: number;
  message: string;
  data?: T;
}

export interface CarrierListResponse extends BaseResponse {
  data: Carrier[] | null;
}

export interface DepartureListResponse extends BaseResponse {
  data: Location[] | null;
}

export interface DestinationListResponse extends BaseResponse {
  data: Destination[] | null;
}

export interface SimpleFlightQueryResponse extends BaseResponse {
  data: FlightList[] | null;
}

// 页面查询表单数据
export interface FlightSearchForm extends FlightQueryCondition {
  current_page: number;
  page_size: number;
}

// 航班搜索状态管理
export interface FlightSearchState {
  isLoading: boolean;
  flightData: FlightList[];
  carriers: Carrier[];
  departures: Location[];
  destinations: Destination[];
  total: number;
  currentPage: number;
  pageSize: number;
  searchCondition: FlightSearchForm;
  // 缓存的选项数据
  cachedCarriers: Carrier[];
  cachedDepartures: Location[];
  cachedDestinations: Destination[];
}
